﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour {
    [Header("摄像机跟随的物体")]
    public Transform target;
    [Header("偏移量")]
    public Vector3 offset;
    [Header("移动速度")]
    public float speed;

    private AudioSource source;

    public float y;
	// Use this for initialization
	void Start () {
        source = GetComponent<AudioSource>();
	}
    
	// Update is called once per frame
	void Update () {
        Vector3 vector3 = new Vector3(target.position.x + offset.x, y, transform.position.z);
        transform.position = Vector3.Lerp(transform.position, vector3, Time.deltaTime * speed);
        if (scenes2Ui.ui.sourceValue==-1)
        {
            source.mute = true;
        }
        else
        {
            source.mute = false;
        }
	}
}
